We have already seen the integer type used in our programs. This holds a range of integer values which depends on the version of C you are using.

You should only use integers if the numbers you are working on are bigger than 255, since using integers takes up much more storage space and the program has to work much harder to manipulate them.

The compiler also puts a limit on the complexity of integer expressions which you can create.

Note that C lets you create signed and unsigned variables. By default (i.e. if you do nothing extra) the variables are signed. This is useful if you need to hold negative numbers, but because of the way that numbers are stored this reduces your range by half. If all you want to store is positive numbers you can double the range of possible values a variable can have by making them unsigned. As an example:

char c ; /* signed character with range -128 to +127 */

unsigned char cu ; /* unsigned character with range 0 to 255  */

Putting the keyword unsigned in front of a variable tells the compiler that you are not interested in the negative values but you want the maximum possible range. Unfortunately, if you are so silly as to try to put a negative value into something which you have declared as unsigned the program will not detect this as an error, and do something with a value that you almost certainly did not expect. So, you must be absolutely sure that your values will never be negative if you make the variables unsigned.